<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars
define("PRIMARY_KEY","nobkt");
$PRIMARY_KEY    = PRIMARY_KEY;
$PRIMARY_VALUE  = GetParam($PRIMARY_KEY,"");

$FileTemplate   = "ais_transaction_advreport_opr_formmemo.html";

$TableName      = "ais_memorial";
$HTMLFormName   = "AdvanceSummaryForm";
$MaxGrid        = "100";
//$HTMLFormName2  = "BudgetForm";
$FileName = "ais_transaction_advreport_opr.php";

//echo "$FileName";
$FormAction    = $FileName . "?" . AddParam(GetQueryString("QueryString", ""),"form","$HTMLFormName");
$FormEncType   = "application/x-www-form-urlencoded";
//$PMode         = "";

$noref = GetParam("noref","");
$norefBS = GetParam("refBS","");
//echo "$norefBS"; exit;

//Initiate Grid Fields;
$FormFields    = array("uraian"=>"0","jo_costing_id"=>"","urut"=>"","skada"=>"","jumlah"=>"number","dk"=>"0","noorder"=>"","noref"=>"","voyage"=>"","memorial_id"=>"","kdact"=>"");

// Retrieve data From Ref Record
$OfficeID = GetOfficeID();
$REF = GetParam("noref","");
$SQL = "SELECT debtur, debnam FROM $TableName WHERE nobkt='".GetParam("noref","")."' AND ktrasl='".GetOfficeID()."'";
$Result = $DBConnection->dbc->get_row($SQL);
$DEBTUR = $Result->debtur;
$DEBNAM = $Result->debnam;

//buildsqlfield ("$TableName", $FormFields);

//Leave Here Untouch
$FormCName     = BuildHTMLField($FormFields,"name",1);
$FormCValue    = BuildHTMLField($FormFields,"value",1);


//Get Update Preparation ND

$SQL_1 = "SELECT * FROM ais_memorial WHERE noref = '".$project_id."'";
$Result_1  = $DBConnection->dbc->get_row($SQL_2,ARRAY_A);

//


//************ FORM ACTION **************
if (trim(GetParam("form",""))==trim($HTMLFormName)) {
    if (GetParam("FormAction","")=="Save") {
        list($FDay,$FMonth,$FYear) = explode("/",GetParam("tglbkt",""));
        $tglbkt = "$FYear-$FMonth-$FDay";
        $rate    = StrToNumber (GetParam("rate",""));


        if (trim(GetParam("nobkt",""))=="AUTO NUMBERED BY SYSTEM")  {
            $ObjNumber  = new autonumber(GetParam("tglbkt",""));
            $TransNo = $ObjNumber->GetNumber("MB");


            FormSave("ais_memorial", "jumlah", $FormFields, array("ledger"=>GetPeriod(GetParam("tglbkt","")),"curr"=>GetParam("curr",""),"debtur"=>GetParam("debtur",""),"debnam"=>GetParam("debnam",""),"rate"=>$rate,"tglbkt"=>$tglbkt,"nobkt"=>$TransNo,"ktrasl"=>GetOfficeID()),"memorial_id");

            $SQLUpdateBSProgress = "UPDATE ais_advance SET bs_progress = 'closed' WHERE nobkt='$norefBS'";
            $DBConnection->dbc->query($SQLUpdateBSProgress);

            $DBConnection->add_data("ais_memorial","urut","999");
            $DBConnection->add_data("ais_memorial","ktrasl",GetOfficeID());
            $DBConnection->add_data("ais_memorial","kdbank",GetParam("kdbank",""));
            $DBConnection->add_data("ais_memorial","ledger",GetPeriod(GetParam("tglbkt","")));
            $DBConnection->add_data("ais_memorial","curr",GetParam("curr",""));
            $DBConnection->add_data("ais_memorial","kdact",GetParam("kdact999",""));
            $DBConnection->add_data("ais_memorial","rate",$rate);
            $DBConnection->add_data("ais_memorial","nobkt",$TransNo);
            $DBConnection->add_data("ais_memorial","tglbkt",$tglbkt);
            $DBConnection->add_data("ais_memorial","dk",GetParam("dk999",""));
            $DBConnection->add_data("ais_memorial","noorder",GetParam("noorder999",""));
            $DBConnection->add_data("ais_memorial","debtur",GetParam("debtur",""));
            $DBConnection->add_data("ais_memorial","debnam",GetParam("debnam",""));
            $DBConnection->add_data("ais_memorial","skada",GetParam("skada999",""));
            $DBConnection->add_data("ais_memorial","princ",GetParam("princ999",""));
            $DBConnection->add_data("ais_memorial","vessel",GetParam("vessel999",""));
            $DBConnection->add_data("ais_memorial","voyage",GetParam("voyage999",""));
            $DBConnection->add_data("ais_memorial","port",GetParam("port999",""));
            $DBConnection->add_data("ais_memorial","uraian",GetParam("uraian999",""));
            $DBConnection->add_data("ais_memorial","jumlah",StrToNumber(GetParam("total_trans","")));
            $DBConnection->add_data("ais_memorial","rupiah",StrToNumber(GetParam("total_trans","")) * $rate);
            $DBConnection->add_data("ais_memorial","noref",GetParam("noref1",""));
            $DBConnection->InsertGrid();
            UpdateHistory(GetParam("noref1",""), $TransNo,GetParam("total_trans",""));

        } else {
            $TransNo = GetParam("nobkt","");

            FormSave("ais_memorial", "jumlah", $FormFields, array("ledger"=>GetPeriod(GetParam("tglbkt","")),"curr"=>GetParam("curr",""),"debtur"=>GetParam("debtur",""),"debnam"=>GetParam("debnam",""),"rate"=>$rate,"tglbkt"=>$tglbkt,"nobkt"=>$TransNo,"ktrasl"=>GetOfficeID(),"kdact"=>GetParam("kdact","")),"memorial_id");

            $DBConnection->dbc->query("DELETE FROM ais_memorial WHERE nobkt='".$TransNo."' AND ktrasl='".GetOfficeID()."' AND urut=999");

            $DBConnection->add_data("ais_memorial","urut","999");
            $DBConnection->add_data("ais_memorial","ktrasl",GetOfficeID());
            $DBConnection->add_data("ais_memorial","kdbank",GetParam("kdbank",""));
            $DBConnection->add_data("ais_memorial","ledger",GetPeriod(GetParam("tglbkt","")));
            $DBConnection->add_data("ais_memorial","curr",GetParam("curr",""));
      $DBConnection->add_data("ais_memorial","kdact",GetParam("kdact999",""));
            $DBConnection->add_data("ais_memorial","rate",$rate);
            $DBConnection->add_data("ais_memorial","nobkt",$TransNo);
            $DBConnection->add_data("ais_memorial","tglbkt",$tglbkt);
            $DBConnection->add_data("ais_memorial","dk",GetParam("dk999",""));
            $DBConnection->add_data("ais_memorial","noorder",GetParam("noorder999",""));
            $DBConnection->add_data("ais_memorial","debtur",GetParam("debtur",""));
            $DBConnection->add_data("ais_memorial","debnam",GetParam("debnam",""));
            $DBConnection->add_data("ais_memorial","skada",GetParam("skada999",""));
            $DBConnection->add_data("ais_memorial","princ",GetParam("princ999",""));
            $DBConnection->add_data("ais_memorial","vessel",GetParam("vessel999",""));
            $DBConnection->add_data("ais_memorial","voyage",GetParam("voyage999",""));
            $DBConnection->add_data("ais_memorial","port",GetParam("port999",""));
            $DBConnection->add_data("ais_memorial","uraian",GetParam("uraian999",""));
            $DBConnection->add_data("ais_memorial","jumlah",StrToNumber(GetParam("total_trans","")));
            $DBConnection->add_data("ais_memorial","rupiah",StrToNumber(GetParam("total_trans","")) * $rate);
            $DBConnection->add_data("ais_memorial","noref",StrToNumber(GetParam("noref1","")));
            $DBConnection->InsertGrid();

            UpdateHistory(GetParam("noref1",""), $TransNo,GetParam("total_trans",""));
        }

        //DeleteRecord ("txtCheck",$MaxGrid);
        //echo "$FileName"; exit;
        header("Location: $FileName?PageMode=Form&".PRIMARY_KEY."=".$TransNo);
        exit;

    }
    if (GetParam("FormAction","")=="Delete") {
//      print "Deleted"."<br>\n";
        DeleteRecord ("txtCheck",$MaxGrid);
    }
}

//Field Verification
$Verification  = "False";
$SessionVar    = md5(microtime());
//$SessionVar    = "Stuck";
$VerifyFields = array("nobkt"=>"ID No.","tglbkt"=>"Transaction Date","curr"=>"Currency","skada1"=>"Skada On Line 1","uraian1"=>"Uraian On Line 1","uraian999"=>"Uraian On Line 999");
VerifyHTML ($HTMLFormName,$VerifyFields,$SessionVar,"");

if (GetParam(PRIMARY_KEY,"")) {
    $SQLCount     = "SELECT count(*) FROM `$TableName`";
    $SQLCount    .= "WHERE ".PRIMARY_KEY."='".$PRIMARY_VALUE."' AND urut<>999";
    $Count        = $DBConnection->dbc->get_var($SQLCount);
} else $Count=0;

$NewDataStart = $Count + 1;
$InitFunction = "Masking();Masking2();";

$VerifyGrids = array("uraian"=>"0","jumlah"=>"number","skada"=>"0");
$Masking1 = BuildMasking ($HTMLFormName,MutatorFields($FormFields,($MaxGrid+$Count)));
$Masking2 = BuildMasking ($HTMLFormName,array("tglbkt"=>"date","rate"=>"number"),"2");
$JSMasks  = $Masking1.$Masking2;

Init($SessionVar,$JSMasks);
FormGridHTML ($HTMLFormName,$VerifyGrids,$Count,$MaxGrid,$SessionVar);



//************ SET FORM MODE ***************
if (GetParam(PRIMARY_KEY,"")) $FormMode = "Edit";
else $FormMode = "Add";

//******* DATABASE GRID QUERY ***********

$SQL = "SELECT ".BuildFields($FormFields)." FROM `$TableName`";
if (GetParam(PRIMARY_KEY,"") && $FormMode="Edit") {
    $SQL      = $SQL."WHERE ".PRIMARY_KEY." ='".GetParam(PRIMARY_KEY,"")."'";
    $SQL     .= " AND ktrasl='".GetOfficeID()."'";
    $SQLGrid  = $SQL." ORDER BY ".PRIMARY_KEY;
}





//******* SHOW FORM CONTENT *********
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);

//********************************* HTML Header ******************************************
//Select Currency Table
$SQLCurr = "SELECT * FROM tblcurrency";
//Select Department:
$SQLDept = "SELECT * FROM tbldept";
//Select Receipt:
$SQLReceipt = "SELECT * FROM tblreceipt";
//Select Bank:
$SQLBank = "SELECT * FROM tblbank ORDER BY banknam";
//Select Activity Code
$SQLAct = "SELECT * FROM tblactivity ORDER BY actname";
//Select Curr
$SQLCurrSel = "SELECT DISTINCT curr FROM ais_memorial "."WHERE ".PRIMARY_KEY." ='".GetParam("noref","")."' AND ktrasl='".GetOfficeID()."'";
$TBS->MergeBlock("currency",$DBMysql,$SQLCurrSel);

$HeaderFields = array("nobkt"=>"0","tglbkt"=>"date","curr"=>"","rate"=>"number","debtur"=>"","debnam"=>"","kdact"=>"");
//Leave Here Untouch
$FormHName     = BuildHTMLField($HeaderFields,"name",1);
$FormHValue    = BuildHTMLField($HeaderFields,"value",1);
$SQLHeader     = "SELECT ".BuildFields($HeaderFields)." FROM $TableName ";

if (GetParam(PRIMARY_KEY,"") && $FormMode="Edit") $SQLHeader .= "WHERE ".PRIMARY_KEY."='".GetParam(PRIMARY_KEY,"")."' AND ktrasl='".GetOfficeID()."'";
$TBS->MergeBlock("currformblk",$DBMysql,$SQLCurr);
$TBS->MergeBlock("receiptblk",$DBMysql,$SQLReceipt);
$TBS->MergeBlock("actblk",$DBMysql,$SQLAct);

//Total 999 Values
/*
$Fields9       = array("noref999"=>"0","jumlah999"=>"number","skada999"=>"0","untush999"=>"0");
$Form9Value    = BuildHTMLField($Fields9,"value",1);
*/
if (GetParam("noref",""))
    $SQL999 = "SELECT uraian,jumlah,dk,skada,noorder,memorial_id,princ,kdact,'".GetParam("noref","")."' as noref, vessel,voyage,port FROM ais_memorial "."WHERE ".PRIMARY_KEY." ='".GetParam("noref","")."' AND ktrasl='".GetOfficeID()."' ";
else
    $SQL999 = "SELECT * FROM ais_memorial "."WHERE ".PRIMARY_KEY." ='".GetParam(PRIMARY_KEY,"")."' AND ktrasl='".GetOfficeID()."' ";
$SQL999 = $SQL999." AND urut = 999";
//print $SQL999;


if (GetParam(PRIMARY_KEY,"") || GetParam("noref","")) {
    $TBS->MergeBlock("blg9",$DBMysql,$SQL999);
}
else $TBS->MergeBlock("blg9",$FormCValue);

// HTML Value
$TBS->MergeBlock("headbln",$FormHName);
if (GetParam(PRIMARY_KEY,"")) {$TBS->MergeBlock("headblv",$DBMysql,$SQLHeader);}
else $TBS->MergeBlock("headblv",$FormHValue);



//********************************* HTML GRID *********************************************
//HTML Grid
if (GetParam("noref","")) {
  $SQLGrid = "SELECT * FROM ais_memorial "."WHERE ".PRIMARY_KEY." ='".GetParam("noref","")."' AND ktrasl='".GetOfficeID()."' AND urut<>999";
} else {
  $SQLGrid = "SELECT * FROM ais_memorial "."WHERE ".PRIMARY_KEY." ='".GetParam(PRIMARY_KEY,"")."' AND ktrasl='".GetOfficeID()."' AND urut<>999";
}


$Result  = $DBConnection->dbc->get_results($SQLGrid,ARRAY_A);
$Result  = BuildEmptyGrid ($FormFields, $MaxGrid, $Result);
//$Result  = BuildEmptyGrid ($FormFields, $MaxGrid, $Result);



$TBS->MergeBlock("blg",$Result);
$TBS->Show();


//*************** ACTION FUNCTION *******************
function FormInsert() {
    global $DBConnection,$FileName;
    $DBConnection->Insert();
    header("Location: $FileName?PageMode=Form");
    exit;
}

function FormUpdate() {
    global $DBConnection;
    $DBConnection->Update();
}

function FormDelete() {
    global $DBConnection,$FileName,$TableName;
    $DBConnection->deleteGrid("$TableName","nobkt");
    header("Location: $FileName");
    exit;
}

function FormSearch () {

}

function FormCancel () {
    global $FileName;
    header("Location: ".$FileName);
    exit;
}



function FormSave ($table, $keyField, $FormFields, $SpecialCase="", $PrimaryKey="", $PrimaryKeyVal="",$PrimaryKey_log="", $PrimaryKeyVal_log="") {
        global $FileName, $MaxGrid, $DBConnection;
        $TotalData = $MaxGrid * 2;
        $NewDataStart = GetParam("NewData","0");
        $NewDataStart = 1;



        for ($a=1;$a<=$MaxGrid;$a++) {
        //Begin For


            if (GetParam($keyField.$a,""))
            {
            //Begin Check if Empty Keyfield


                foreach ($FormFields as $key=>$formatting) {

                        if(!empty($PrimaryKeyVal))
                        {
                            $value = GetParam($key.$a,"");

                            if ($formatting=="number") $value = str_replace(",","",$value);
                            if ($formatting=="date")
                            {
                                    list($day,$month,$year) = explode("/",$value);
                                    $value = "$year-$month-$day";
                            }
                            //Inser if the key is equal primary key, then set valu = primary header

                            if($key == "$PrimaryKey")
                            {
                               $DBConnection->add_data($table,$key,$PrimaryKeyVal);
                            }

                            else if($key == "jo_costing_id")
                            {
                               $DBConnection->add_data($table,$key,$value);
															  
                               $jumlah = str_replace(",","",GetParam("jumlah".$a,""));
                               $jumlah_temp = str_replace(",","",GetParam("jumlah_temp".$a,""));
															  
                               $total_compare = $jumlah_temp - $jumlah;
															 	
                               //if($total_compare == 0)
                               //{
															 
                               $SQLStatus = "UPDATE tbljoborder_costing SET payment_complete = 'complete' WHERE jo_costing_id = '".$value."'";
                               $DBConnection->dbc->query($SQLStatus);



                               // PROCESS UPDATE TO ND STATUS

                               $SQLgetjo = "SELECT * FROM tbljoborder_costing WHERE jo_costing_id = '".$value."'";
                               $Resultgetjo  = $DBConnection->dbc->get_results($SQLgetjo,ARRAY_A);

                               //Assignment
                               $checkJO = $Resultgetjo[0]['jo_id'];
                               $checkServices = $Resultgetjo[0]['services_id'];

                               //Check IF Complete Exist
                               $checkComplete = "SELECT count(*) as record_complete FROM tbljoborder_costing
                                                 WHERE jo_id = '".$checkJO."' AND services_id = '".$checkServices."' AND payment_complete = '' ";


                               $ResultComplete = $DBConnection->dbc->get_results($checkComplete,ARRAY_A);

                               //Check if the result equal 0, then all the services is complete
                               $zero_complete = $ResultComplete[0]['record_complete'];

                               if($zero_complete <= 0)
                               {

                                  $SQLStatusND = "UPDATE tbljoactivity SET bill_nd = 'set'
                                                  WHERE jo_id = '".$checkJO."' AND services_id = '".$checkServices."' ";
                                  //INACTIVE                                   
                                  //$DBConnection->dbc->query($SQLStatusND);

                               }


                               // PROCESS END UPDATE TO ND STATUS



                               //}

                            }


                            else
                            {
                               $DBConnection->add_data($table,$key,$value);
                            }

                        }

                        else
                        {
                            $value = GetParam($key.$a,"");

                            if ($formatting=="number") $value = str_replace(",","",$value);
                            if ($formatting=="date")
                            {
                                    list($day,$month,$year) = explode("/",$value);
                                    $value = "$year-$month-$day";
                            }

                            else if($key == "jo_costing_id")
                            {
                               $DBConnection->add_data($table,$key,$value);

                               $jumlah = str_replace(",","",GetParam("jumlah".$a,""));
                               $jumlah_temp = str_replace(",","",GetParam("jumlah_temp".$a,""));

                               $total_compare = $jumlah_temp - $jumlah;

                               //if($total_compare == 0)
                               //{

                               $SQLStatus = "UPDATE tbljoborder_costing SET payment_complete = 'complete' WHERE jo_costing_id = '".$value."'";
                               $DBConnection->dbc->query($SQLStatus);



                               // PROCESS UPDATE TO ND STATUS

                               $SQLgetjo = "SELECT * FROM tbljoborder_costing WHERE jo_costing_id = '".$value."'";
                               $Resultgetjo  = $DBConnection->dbc->get_results($SQLgetjo,ARRAY_A);

                               //Assignment
                               $checkJO = $Resultgetjo[0]['jo_id'];
                               $checkServices = $Resultgetjo[0]['services_id'];

                               //Check IF Complete Exist
                               $checkComplete = "SELECT count(*) as record_complete FROM tbljoborder_costing
                                                 WHERE jo_id = '".$checkJO."' AND services_id = '".$checkServices."' AND payment_complete = '' ";


                               $ResultComplete = $DBConnection->dbc->get_results($checkComplete,ARRAY_A);

                               //Check if the result equal 0, then all the services is complete
                               $zero_complete = $ResultComplete[0]['record_complete'];


                               if($zero_complete <= 0)
                               {

                                  $SQLStatusND = "UPDATE tbljoactivity SET bill_nd = 'set'
                                                  WHERE jo_id = '".$checkJO."' AND services_id = '".$checkServices."' ";
                                  //INACTIVE
                                  //$DBConnection->dbc->query($SQLStatusND);

                               }


                               // PROCESS END UPDATE TO ND STATUS



                               //}

                            }

                            else
                            {
                              $DBConnection->add_data($table,$key,$value);
                            }


                        }

                }
        
                $rate = StrToNumber(GetParam("rate",""));
                $jmh  = StrToNumber(GetParam("jumlah".$a,""));
								$rupiah = $rate * $jmh;
        				$DBConnection->add_data($table,"rupiah",$rupiah);
								
                // Add by Chandra (15 May 2009)
                $cash_type = GetParam("cash_type","");
                //var_dump($cash_type); exit;



                if($cash_type) $DBConnection->add_data($table,'cash_type',$cash_type);
                // end update


                if (strlen($SpecialCase))
                {
                        foreach ($SpecialCase as $key => $value)
                        {
                                //print "add_data($table,$key,$value);<br>";
                                $DBConnection->add_data($table,$key,$value);
                        }
                }

//                print "$a < $NewDataStart<br>";
                if ($a < $NewDataStart)
                {
                         if (strlen($PrimaryKey))
                         {
                            $DBConnection->UpdateGrid($PrimaryKey,GetParam($PrimaryKey.$a,""));
                         }
                         else
                         {
                            $DBConnection->UpdateGrid($keyField,GetParam($keyField.$a,""));
                         }
                }

                else
                {
                        $DBConnection->InsertGrid();
//                        $DBConnection->dbc->debug();
                }


            //End Check if Empty Keyfield
            }


        //End For
        }
        $DBConnection->ClearData();
}



/*
function FormSave ($table, $keyField, $FormFields, $SpecialCase="", $PrimaryKey) {
    global $FileName, $MaxGrid, $DBConnection;
    $TotalData = $MaxGrid * 2;
    $NewDataStart = GetParam("NewData","0");
    for ($a=1;$a<=$TotalData;$a++) {
        foreach ($FormFields as $key=>$formatting) {
            if (!GetParam($keyField.$a,"")) {
                $EndOfData = 1;
                break;
            }
            $value = GetParam($key.$a,"");
            if ($formatting=="number") $value = str_replace(",","",$value);
            if ($formatting=="date") {
                list($day,$month,$year) = explode("/",$value);
                $value = "$year-$month-$day";
            }
            $DBConnection->add_data($table,$key,$value);
        }
        $rate = StrToNumber(GetParam("rate",""));
        $jmh  = StrToNumber(GetParam("jumlah".$a,""));
        $rupiah = $rate * $jmh;
        $DBConnection->add_data($table,"rupiah",$rupiah);
        if ($EndOfData) {
            break;
        }
        if (strlen($SpecialCase)) {
            foreach ($SpecialCase as $key => $value) {
            //  print "add_data($table,$key,$value);<br>";
                $DBConnection->add_data($table,$key,$value);
            }
        }
//      print "$a < $NewDataStart<br>";
        if ($a < $NewDataStart) {
             if (strlen($PrimaryKey)) {
                $DBConnection->UpdateGrid($PrimaryKey,GetParam($PrimaryKey.$a,""));
             } else {
                $DBConnection->UpdateGrid($keyField,GetParam($keyField.$a,""));
             }
        } else {
            $DBConnection->InsertGrid();
        }
    }
    $DBConnection->clearData();
}
*/



//*************** USER FUNCTION *******************
function buildsqlfield ($table, $arrayfield) {
        global $DBConnection;
        for ($x=0;$x<count($arrayfield);$x++) {
            $DBConnection->add_htmlfield($table,$arrayfield[$x],GetParam($arrayfield[$x],""));
        }
}

function DeleteRecord ($sequence_name,$PageSize) {
    global $DBConnection,$FileName,$TableName;
    for ($x=1;$x<=$PageSize;$x++) {
        if (GetParam($sequence_name.$x,"")) {
            $DBConnection->deleteGrid("$TableName","receipt_id",$sequence_name.$x);
        }
    }
}

function BuildFields ($FormFields) {
        global $DBConnection;
        $str = "";
        foreach ($FormFields as $key=>$formatting) {
            if (strlen($str)) $str .= ",$key";
            else $str = "$key";
        }
        return $str;
}

function MutatorFields ($FormFields, $MaxGrid) {
        global $DBConnection;
        $array_fields = array();
        for ($x=0;$x<$MaxGrid;$x++) {
            foreach ($FormFields as $key=>$formatting){
                $a=$x+1;
                $array_fields[$key.$a] = "$formatting";
            }
        }
        return $array_fields;
}

function UpdateHistory($refno, $nobkt,$value) {
    global $DBConnection;
    $SQL = "SELECT COUNT(*) FROM ais_history_trans WHERE entry2 = '".$refno."'";
    $isExist = $DBConnection->dbc->get_var($SQL);
    if ($isExist) {
        $DBConnection->dbc->query("UPDATE ais_history_trans SET amount3 = '".StrToNumber($value)."', entry3='$nobkt' WHERE entry2='$refno' AND ktrasl='".GetOfficeID()."'" );
    }
}

?>
